package loon.srpg.view;

import loon.core.LSystem;
import loon.core.graphics.LColor;
import loon.core.graphics.LFont;
import loon.core.graphics.LGradation;
import loon.core.graphics.opengl.GLEx;
import loon.srpg.ability.SRPGAbilityFactory;
import loon.srpg.actor.SRPGStatus;

/**
 * 
 * 技能名字窗口，还有显示角色设置的名字
 *
 */
public class SRPGAbilityNameView extends SRPGDrawView {

	private final static LFont defFont = LFont.getFont("Dialog", 0, 12);

	private SRPGAbilityFactory ab;

	private SRPGStatus status;

	private int namelen;
	/**
	 * 显示技能和角色设置名字
	 * @param ability 技能
	 * @param status 角色设置
	 */
	public SRPGAbilityNameView(SRPGAbilityFactory ability, SRPGStatus status) {
		this.setExist(true);
		this.setLock(false);
		super.width = LSystem.screenRect.width;
		super.height = defFont.getHeight();
		this.ab = ability;
		this.status = status;
		this.namelen = defFont.stringWidth(status.name);
	}

	@Override
	public void draw(GLEx g) {
		LFont old = g.getFont();
		g.setColor(LColor.white);
		g.setFont(defFont);
		LColor color = LColor.blue;
		if (status.team != 0) {
			color = LColor.red;
		}
		LColor color1 = LColor.black;
		LGradation.getInstance(color, color1, super.width, super.height)
				.drawWidth(g, super.left, super.top);
		g.setColor(LColor.white);
		g.drawString(ab.getAbilityName(), 5 + super.left, 12 + super.top);
		g.drawString(status.name, (super.width - namelen - 5) + super.left,
				12 + super.top);
		g.setFont(old);
		g.resetColor();
	}

}
